package com.six.apidemic.httpapi;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;

/**
 * 联网工具类
 */
public class HTTPAPI {

    public static HTTPAPI instance;

    public static HTTPAPI getInstance(){
        if (instance == null) {
            instance = new HTTPAPI();
        }
        return instance;
    }

    /**
     * 注册
     * @param name      姓名
     * @param address   地址
     * @param age       年龄
     * @param idCard    身份证号码
     * @param mobile    电话号码
     * @param password  密码
     * @param sex       性别
     * @param status    状态
     * @param type      角色 0用户 1企业 2流调人员
     * @param callback
     */
    public void toRegister(String name,String address,String age,String idCard,String mobile,String password,
                           String sex,String status,String type,StringCallback callback){
        OkGo.post(Constract.HTTPAPI_REGISTER)
                .tag(this)
                .connTimeOut(30000)
                .params("name",name)
                .params("address",address)
                .params("age",age)
                .params("idCard",idCard)
                .params("mobile",mobile)
                .params("password",password)
                .params("sex",sex)
                .params("status",status)
                .params("type",type)
                .params("status",status)
                .execute(callback);
    }


    /**
     * 登录接口
     * @param name
     * @param password
     * @param callback
     */
    public void toLogin(String name,String password,StringCallback callback){
        OkGo.post(Constract.HTTPAPI_LOGIN)
                .tag(this)
                .connTimeOut(30000)
                .params("name",name)
                .params("password",password)
                .execute(callback);
    }

    /**
     * 获取危险场所
     * @param callback
     */
    public void getManTrapList(StringCallback callback){
        OkGo.get(Constract.HTTPAPI_MAN_TRAP)
                .tag(this)
                .connTimeOut(30000)
                .execute(callback);
    }


    /**
     * 获取人员列表
     * @param callback
     */
    public void getPersonList(StringCallback callback){
        OkGo.get(Constract.HTTPAPI_PERSON_LIST)
                .tag(this)
                .connTimeOut(30000)
                .execute(callback);
    }

    /**
     * 改变个人状态
     * @param id
     * @param status
     * @param callback
     */
    public void toChangeType(String id,String status,StringCallback callback){
        OkGo.post(Constract.HTTPAPI_CHANGE_TYPE)
                .tag(this)
                .connTimeOut(30000)
                .params("id",id)
                .params("status",status)
                .execute(callback);
    }

    /**
     * 个人信息
     * @param name
     * @param callback
     */
    public void getPersonInformation(String name,StringCallback callback){
        OkGo.get(Constract.HTTPAPI_GET_PERSON_INFORMATION)
                .tag(this)
                .connTimeOut(30000)
                .params("name",name)
                .execute(callback);
    }

    /**
     * 扫码
     * @param enterpriseId      企业ID
     * @param personId          扫码人ID
     * @param callback
     */
    public void toScan(String enterpriseId,String personId,StringCallback callback){
        OkGo.post(Constract.HTTPAPI_TO_SCAN)
                .tag(this)
                .connTimeOut(30000)
                .params("enterpriseId",enterpriseId)
                .params("personId",personId)
                .execute(callback);
    }


    /**
     * 获取扫描记录
     * @param personId
     * @param callback
     */
    public void getScanHistoryList(String personId,StringCallback callback){
        OkGo.get(Constract.HTTPAPI_GET_SCAN_HISTORY)
                .tag(this)
                .connTimeOut(30000)
                .params("personId",personId)
                .execute(callback);
    }
}
